import webview
import common
import pyautogui
import time

import config, moment, sn

pyautogui.FAILSAFE = False

class Api:
    def saveConfig(self, data):
        config.saveConfig(data)
        return "保存成功"
    
    def momentGo(self):
        result = common.wechat_init()
        if result != True: return result

        time.sleep(1)
        moment.go()

    def snCheck(self):
        return sn.snCheck()

def loadConfig():
    evaluate_js("readConfig("+ str(config.getConfig()) +")")

def evaluate_js(js_code):
    global window
    # print(js_code)
    window.evaluate_js(js_code)


api = Api()
window = webview.create_window("点赞朋友圈, 让你的好友关系更亲密 || 艾思软件出品", "./web/set.html", 
                        js_api=api, 
                        width=1200, 
                        height=800,
                        #confirm_close=True
                    )
webview.start(loadConfig)


